<?php
namespace app\index\controller;

use app\common\model\CommonModel;

class Index extends Common
{

    public function index()
    {
        if ($this->request->isAjax()) {
            $param = $this->request->post();
            if (empty($param['database'])) {
                return ['status' => 401, 'info' => '数据库名不能为空'];
            }
            $c   = new CommonModel();
            $sql = "create database {$param['database']}";
            $res = $c->execute($sql);
            if (!$res) {
                return ['status' => 402, 'info' => '创建失败'];
            }
            return ['status' => 200, 'info' => '创建成功'];
        }
        return $this->fetch();
    }

}
